// app/controller/base.js
const Controller = require('egg').Controller;
class BaseController extends Controller {
  success(data = null, message = 'success', code = 200) {
    const { ctx } = this;
    ctx.status = 200;
    ctx.body = {
      code,
      message,
      data,
    };
  }
  fail(data = null, message = 'error', code = 500) {
    const { ctx } = this;
    ctx.status = 500;
    ctx.body = {
      code,
      message,
      data,
    };
  }
}
module.exports = BaseController;
